<?php
namespace app\admin\controller;
use think\Controller;
use think\Session;
use think\Db;
class Allow extends Controller
{
	public function _initialize(){
		//检测用户是否登录
		if(!Session::get('islogin')){
			$this->error("请先登录","/adminlogin/login");
		}
		$request=request();
        $contro=$request->controller();
        $method=$request->action();
		$name=SESSION::get('username');
		$n=Db::table('jdt')->where(['contro'=>$contro,'method'=>$method])->find();
		$pwoer=Db::table('user')->where(['username'=>$name])->find();
		if($pwoer['power']!=0){
			$jiedian=Db::table('node')->where('uid',$pwoer['power'])->find();
			$jie=explode(',',$jiedian['jid']);
			if(!in_array($n['id'],$jie)){
				die("<script>alert('没有权限!');history.back(-1);</script>");
			}
		}

	}
}

?>